#ifndef CURLING_OPENGL_INCLUDED
#define CURLING_OPENGL_INCLUDED

#include <string>
#include <boost/shared_ptr.hpp>
#include "curling/config.hpp"

#ifdef CURLING_PLATFORM_MACOSX
  #include <OpenGL/gl.h>
  #include <OpenGL/glu.h>
  #include <GL/glfw.h>
#endif

#ifdef CURLING_PLATFORM_WINDOWS
  #include <windows.h>
  #include <gl/gl.h>
  #include <gl/glu.h>
  #include <glfw.h>
#endif

namespace glfont {
  class GLFont;
}

namespace curling {

class texture_font_t
{
public:
  
  texture_font_t();
  ~texture_font_t();
  
  double string_width( const std::string& text );
  void render_string( const std::string& text, double scale = 1.0 );
  
private:
  
  GLuint _font_texture;
  boost::shared_ptr<glfont::GLFont> _glfont;
};


	// A class that controls the menu textures.
	// Implemented with a little help from http://gpwiki.org/index.php/Blob_Tutorial

	class Start_Menu_Textures {


	public:
        
        #ifndef __APPLE_CC__
		static
        #endif
        enum MENU_ITEMS {
			SWEDEN_FLAG_ITEM,		
			CANADA_FLAG_ITEM,
			PLAY_ITEM,				
			PLAY_MARKED_ITEM,		
			OPTIONS_ITEM,			
			OPTIONS_MARKED_ITEM,	
			QUIT_ITEM,			
			QUIT_MARKED_ITEM,
			TEAM_ONE_WINS_ITEM,
			TEAM_TWO_WINS_ITEM,
			TEAM_ONE_TROPHY_ITEM,
			TEAM_TWO_TROPHY_ITEM,
			TIE_ITEM,
			TIE_TROPHY,
			NR_OF_ITEMS
		};

		Start_Menu_Textures() {
			initialize();
		
		}

		~Start_Menu_Textures() {
			deinitialize();
		}

		void setColor(float r, float g, float b, float a);

		//Renders a texture with the specified textureID
		void renderTexture(float x, float y, float width, float height, const unsigned int textureID);

		//Renders a texture with the specified textureID, but can flip the Y, so it becomes upside down.
		void renderTexture(float x, float y, const unsigned int textureID, const bool flipY);
		

	private:


		unsigned int textureIDs[NR_OF_ITEMS];

		//Load a texture from file and link to their IDs.
		void loadTexture(const char* filename, unsigned int &_id, bool pureAlpha);

		//Loads all textures from files.
		void initialize();

		//Releases the texture ids.
		void deinitialize();
	};
}

#endif